/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2019年2月11日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.lesson3.linkedList;

/**
 * @Type Node
 * @Desc
 * @author 52489
 * @date 2019年2月11日
 * @Version V1.0
 */
public class LoopNode {

    private int data;
    private LoopNode next;

    public int getData() {
        return data;
    }

    public void setData(int data) {
        this.data = data;
    }

    public LoopNode getNode() {
        return next;
    }

    public void setNode(LoopNode node) {
        this.next = node;
    }

    /**
     * @param data
     */
    public LoopNode(int data) {
        this.data = data;
    }

    public LoopNode append(LoopNode node) {
        LoopNode currentNode = this;
        while (true) {
            if (currentNode.getNode() == null) {
                break;
            }
            currentNode = currentNode.getNode();
        }
        currentNode.setNode(node);
        return this;
    }

    public void removeNext() {
        LoopNode next2Node = getNode().getNode();
        this.setNode(next2Node);
    }

    public void after(LoopNode node) {
        LoopNode next = getNode();
        this.setNode(node);
        node.setNode(next);
    }
}
